$(function(){
		var QUESTIONLISTURL = '/Api.php/Question/quesstionList';
		var listUl = $('#question-list-ul');
    var LIST = [{
			id: 1,
			user_id: 2,
			userInfo: {
				id: 1,
				username: '二蛋',
				headpic: './images/user.png'
			},
			des: '已解决',
			type: ['Java','PHP','JavaScript'],
			title: '腾讯大咖独家揭秘:月薪30k难吗?',
			create_time: '2017.11.8',
			username: 'xiaocheng',
			mobile: '15176243581',
			bonus: 1500,
			answer_id: '21',
			answerInfo: {
				id: '21',
				username: 'xiaocheng1',
				headpic: './images/user.png'
			},
			answer_time: '2017.12.12'
    },{
			id: 1,
			user_id: 2,
			userInfo: {
				id: 1,
				username: '二蛋',
				headpic: './images/user.png'
			},
			des: '已解决',
			type: ['Java','PHP','JavaScript'],
			title: '腾讯大咖独家揭秘:月薪30k难吗?',
			create_time: '2017.11.8',
			username: 'xiaocheng',
			mobile: '15176243581',
			bonus: 1500,
			answer_id: '21',
			answerInfo: {
				id: '21',
				username: 'xiaocheng1',
				headpic: './images/user.png'
			},
			answer_time: '2017.12.12'
    }]
    function getQuestionList () {
			// listUl.html("正在加载...");
			// $.ajax({
			// 	url: QUESTIONLISTURL,
			// 	type: 'POST',
			// 	data: {
			// 		is_personal: 'y'
			// 	},
			// 	success: function (data) {
			// 		if (data.code === 0) {
			// 			var questionList = data.data;
			// 			// 成功之后运行 createQuestionList
			// 		}
			// 	}
			// })
			// var json = {"remember":1,"username":"15176243581","password":"xiaocheng"};
			// json = JSON.stringify(json);
			// $.ajax({
			// 	url: 'http://test.zhaodaka.net/Api.php/user/login',
			// 	type: 'POST',
			// 	data: {
			// 		data: json
			// 	},
			// 	success: function(data) {
			// 		console.log(data);
			// 	}
			// })
			$.ajax({
				url: 'http://test.zhaodaka.net/Api.php/balance/get',
				type: 'POST',
				data: {
					token: "e94460b87f2bf69b1c5f8e27d603f392"
				},
				success: function(data) {
					console.log(data);
				}
			})
		}
		function createQuestionList (list) {
			if (!list) {
				listUl.html("暂无数据!");
				return;
			}
			var htmlTpl = [];
			list.forEach(function(ele, index) {
				htmlTpl.push('<li class="question-list-item">');
					htmlTpl.push('<div class="user-info">');
						htmlTpl.push('<img src=' + ele.answerInfo.headpic + ' alt=' + ele.userInfo.username + ' class="avator" />');
						htmlTpl.push('<p class="name">' + ele.userInfo.username + '</p>');
					htmlTpl.push('</div>');
					htmlTpl.push('<div class="question-des">');
						htmlTpl.push('<h2 class="name">');
							htmlTpl.push('<a href="javascript:void(0)">' + ele.title + '</a>');
						htmlTpl.push('</h2>');
						htmlTpl.push('<div class="tag-group">');
						ele.type.forEach(function(item){
							htmlTpl.push('<span class="btn btn-primary btn-xs">' + item + '</span>');
						})
						htmlTpl.push('</div>');
						htmlTpl.push('<p class="time">Time：' + ele.create_time + '</p>');
					htmlTpl.push('</div>');
					htmlTpl.push('<div class="deg yes">' + ele.des + '</div>')
				htmlTpl.push('</li>');
			});
			listUl.html(htmlTpl.join(''));
		}
		getQuestionList();
		createQuestionList(LIST);
})